package com.jn.sqlhelper.mybatisplus.spring.boot.autoconfigure;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;

public class MyBatisPlusPropertiesClone_GE_3_5_4 implements MyBatisPlusPropertiesClone{
    @Override
    public MybatisPlusProperties cloneObject(MybatisPlusProperties prototype) {
        MybatisPlusProperties newObj = new MybatisPlusProperties();
        newObj.setCheckConfigLocation(prototype.isCheckConfigLocation());
        newObj.setConfigLocation(prototype.getConfigLocation());
        newObj.setMapperLocations(prototype.getMapperLocations());
        newObj.setTypeAliasesPackage(prototype.getTypeAliasesPackage());
        newObj.setTypeAliasesSuperType(prototype.getTypeAliasesSuperType());
        newObj.setTypeHandlersPackage(prototype.getTypeHandlersPackage());
        newObj.setExecutorType(prototype.getExecutorType());
        newObj.setConfigurationProperties(prototype.getConfigurationProperties());
        newObj.setGlobalConfig(prototype.getGlobalConfig());
        newObj.setDefaultScriptingLanguageDriver(prototype.getDefaultScriptingLanguageDriver());

        // 对于 >= 3.5.4 的mybatis-plus， 这个属性的类型发生了变化

        MybatisPlusProperties.CoreConfiguration configurationPrototype = prototype.getConfiguration();

        if (configurationPrototype != null) {
            MybatisPlusProperties.CoreConfiguration configuration = new MybatisPlusProperties.CoreConfiguration();
            configuration.setSafeRowBoundsEnabled(configurationPrototype.getSafeRowBoundsEnabled());
            configuration.setSafeResultHandlerEnabled(configurationPrototype.getSafeResultHandlerEnabled());
            configuration.setMapUnderscoreToCamelCase(configurationPrototype.getMapUnderscoreToCamelCase());
            configuration.setAggressiveLazyLoading(configurationPrototype.getAggressiveLazyLoading());
            configuration.setMultipleResultSetsEnabled(configurationPrototype.getMultipleResultSetsEnabled());
            configuration.setUseGeneratedKeys(configurationPrototype.getUseGeneratedKeys());
            configuration.setUseColumnLabel(configurationPrototype.getUseColumnLabel());
            configuration.setCacheEnabled(configurationPrototype.getCacheEnabled());
            configuration.setCallSettersOnNulls(configurationPrototype.getCallSettersOnNulls());
            configuration.setUseActualParamName(configurationPrototype.getUseActualParamName());
            configuration.setReturnInstanceForEmptyRow(configurationPrototype.getReturnInstanceForEmptyRow());
            configuration.setShrinkWhitespacesInSql(configurationPrototype.getShrinkWhitespacesInSql());
            configuration.setNullableOnForEach(configurationPrototype.getNullableOnForEach());
            configuration.setArgNameBasedConstructorAutoMapping(configurationPrototype.getArgNameBasedConstructorAutoMapping());
            configuration.setLazyLoadingEnabled(configurationPrototype.getLazyLoadingEnabled());
            configuration.setDefaultStatementTimeout(configurationPrototype.getDefaultStatementTimeout());
            configuration.setVariables(configurationPrototype.getVariables());
            configuration.setVfsImpl(configurationPrototype.getVfsImpl());
            configuration.setDefaultFetchSize(configurationPrototype.getDefaultFetchSize());
            configuration.setLocalCacheScope(configurationPrototype.getLocalCacheScope());
            configuration.setJdbcTypeForNull(configurationPrototype.getJdbcTypeForNull());
            configuration.setDefaultResultSetType(configurationPrototype.getDefaultResultSetType());
            configuration.setDefaultExecutorType(configurationPrototype.getDefaultExecutorType());
            configuration.setAutoMappingBehavior(configurationPrototype.getAutoMappingBehavior());
            configuration.setAutoMappingUnknownColumnBehavior(configurationPrototype.getAutoMappingUnknownColumnBehavior());
            configuration.setLogPrefix(configurationPrototype.getLogPrefix());
            configuration.setLazyLoadTriggerMethods(configurationPrototype.getLazyLoadTriggerMethods());
            configuration.setLogImpl(configurationPrototype.getLogImpl());
            configuration.setVfsImpl(configurationPrototype.getVfsImpl());
            configuration.setDefaultSqlProviderType(configurationPrototype.getDefaultSqlProviderType());
            configuration.setDefaultEnumTypeHandler(configurationPrototype.getDefaultEnumTypeHandler());
            configuration.setConfigurationFactory(configurationPrototype.getConfigurationFactory());
            configuration.setVariables(configurationPrototype.getVariables());
            configuration.setDefaultScriptingLanguageDriver(configurationPrototype.getDefaultScriptingLanguageDriver());
            newObj.setConfiguration(configuration);
        }
        return newObj;
    }
}
